package com.example.demo;

import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
import tbs.framework.async.container.IAsyncTaskService;
import tbs.framework.async.task.AbstractAsyncTask;
import tbs.framework.async.task.IResultable;
import tbs.framework.interfaces.IBufferedConsumer;
import tbs.framework.log.ILogger;
import tbs.framework.log.annotations.AutoLogger;

import javax.annotation.Resource;

/**
 * @author Abstergo
 */
@Component
public class BackgroundBufferedConsumerFlusher extends AbstractAsyncTask implements IResultable<String> {
    @Resource
    private IBufferedConsumer<String> consumer;
    private String result;

    @AutoLogger
    ILogger logger;

    public BackgroundBufferedConsumerFlusher() {
        super("BackgroundBufferedConsumerFlusher");
    }

    @Override
    protected void task(@NotNull IAsyncTaskService container) throws Throwable {
        consumer.flush();
    }

    @Override
    public String getResult() {
        return result;
    }

    @Override
    public void setResult(String result) {
        this.result = result;
    }
}
